import 'package:flutter/material.dart';
import 'package:jm_flutter/jm_flutter.dart';

class TestPage extends StatefulWidget {
  const TestPage({super.key});

  @override
  State<TestPage> createState() => _TestPageState();
}

class _TestPageState extends State<TestPage> {
  final tag = "TestPage";
  @override
  Widget build(BuildContext context) {
    return MyScaffold(
      title: "测试",
      actions: [
        MyPopMenu(
            builder: (context) {
              return [
                MyPopMenuItem(
                  title: "6666",
                  onTap: () {},
                ),
                MyPopMenuItem(
                  title: "测试测试测试",
                  onTap: () {},
                ),
                MyPopMenuItem(
                  title: "890709",
                  isDivider: false,
                  onTap: () {},
                ),
              ];
            },
            child: const Padding(
              padding: EdgeInsets.all(12.0),
              child: Icon((Icons.access_time_filled_rounded)),
            )),
      ],
      body: Column(
        children: [
          Row(
            children: [
              MyButton(
                text: "开始",
                onPressed: () async {
                  try {
                    String a = "sdfas";

                    int b = int.parse(a);
                  } catch (exception, stackTrace) {
                    logd("TestPage", "exception: $exception");
                  }
                },
              ),
            ],
          ),
          MyButton(
            text: "SentryUserFeedback",
            onPressed: () async {
              loge("test", "测试错误22！！！");
            },
          ),
          MyPullDownButton(
            itemLabels: const [
              "全部",
              "错误",
              "警告",
              "调试",
              "信息",
            ],
            selectedIndex: 2,
            onSelected: (index) {},
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: MyText("选择Log"),
            ),
          ),
          MyButton(
            text: "弹窗",
            onPressed: () {
              MyDialog(
                title: "标题",
                content: "内容",
                actions: [
                  MyDialogAction(
                    text: "取消",
                    onTap: () {
                      back();
                    },
                  ),
                  MyDialogAction(
                    text: "确定",
                    onTap: () {
                      back();
                    },
                  ),
                ],
              ).show();
            },
          ),
          MyButton(
            text: "输入弹窗(New)",
            onPressed: () {
              const MyTextFieldDialog(
                title: "新键温暖家",
                desc: "asdhasdjl;jasd",
                hintText: "新建市场",
                initText: "4545",
                confirmButtonText: "尽快了解",
              ).show().then((value) {
                logd(tag, "value: $value");
              });
            },
          ),
          MyButton(
            text: "输入密码",
            onPressed: () {
              const MyTextFieldDialog(
                title: "请输入密码",
                hintText: "密码",
                //confirmButtonText: "尽快了解",
                obscureText: true,
              ).show().then((value) {
                logd(tag, "value: $value");
              });
            },
          ),
          MyButton(
            text: "打开开发者模式",
            onPressed: () {
              openDeveloperMode().then((value) {
                logd(tag, "value: $value");
              });
            },
          ),
        ],
      ),
    );
  }
}
